<style type="text/css">
#sidebar{display:none;}
#content{width:960px;}


/*************** @start@ .goodsBrief ***************/
#goodsBrief{/*border-bottom:2px solid #06f;*/ /*height:438px;*/ height:478px; /*max-height:438px;*/ padding-bottom:10px;}
#goodsBrief_left{display:inline-block; width:422px; height:470px;}
#goodsBrief_left img{/*padding:10px; padding-top:0px;*/ width:320px; height:320px; border:1px solid #ccc;}
#goodsBrief_right{display:inline-block; vertical-align:top; /*width:400px;*/ width:520px; height:332px; margin-left:10px;}
#goodsBrief_right .goodsName{padding-bottom:20px; height: 56px;}
#goodsBrief_right .goodsBriefLabel{padding:10px 0px; font-size:larger; /*width:180px;*/}
#goodsBrief_right .goodsPrice{color:#F30;}
#goodsBrief_right #gspecsDl dt{padding-top:10px; font-size:larger; width:180px;}
#goodsBrief_right #gspecsDl dd{/*height:158px;*/ height:288px; /* height:260px; */ /*max-height:288px;*/ white-space:nowrap; overflow:auto;}
#goodsBrief_right #gspecsDl #gspecs th, #goodsBrief_right #gspecsDl #gspecs td{width:80px; padding:5px; text-align:left;
	background:#f3f3f3;}
#goodsBrief_right #gspecsDl #gspecs .gspecIdRadio{width:20px; padding:5px; text-align:left;
	background:#f3f3f3;}
#addCartUl{margin-top:10px;}
#addCartUl li{height:35px; list-style:none; float:left; margin-right:20px;}
#addCartUl li span{display:inline-block; padding:8px; padding-left:0;}
#addCartUl li a{/*padding-top:5px;*/ display:inline-block; width:80px; padding:10px; text-align:center; color:#fff; background:#06f;}
/*************** @end@ .goodsBrief ***************/

/*************** @start@ .goodsDescription ***************/
#goodsDescription{padding-bottom:10px;}
#goodsDescription #tabTitleBlock ul{/*border-bottom:1px solid #ccc;*/ border-bottom:2px solid #06f;}
#goodsDescription #tabTitleBlock li{display:inline-block; width:100px; margin-right:5px; padding:10px; border:1px solid #ccc; border-bottom:0px; font-size:medium; list-style:none; text-align:center; cursor:pointer;}
#goodsDescription #tabTitleBlock li.active{/*color:#06f; background:#f3f3f3;*/ background:#06f; color:#fff; border:0px;}
#goodsDescription #gattrs{background:#f3f3f3; padding:10px; margin-bottom:10px;}
#goodsDescription #gattrs li{display:inline-block; /*width:225px;*/ width:215px; margin-left:15px; padding:5px 0; overflow:hidden; text-overflow:ellipsis;
    white-space:nowrap;}
#goodsDescription #tabContentBlock #goodsHistoryContent{display:none; padding:10px;}
/*************** @end@ .goodsDescription ***************/

/************** 放大镜 @start@ **************/
.preview{width:402px; height:465px; /*322px; height:385px;*/ /*margin:50px 0px 0px 150px;*/}
/* smallImg */
.smallImg{position:relative; height:52px; margin-top:1px; background-color:#F1F0F0; padding:6px 5px; /*width:390px;*/ width:392px; overflow:hidden;float:left;}
.scrollbutton{width:14px; height:50px; overflow:hidden; position:relative; float:left; cursor:pointer; }
.scrollbutton.smallImgUp , .scrollbutton.smallImgUp.disabled{background:url("/module/foreground/pc/packs/zoom/images/d_08.png") no-repeat;}
.scrollbutton.smallImgDown , .scrollbutton.smallImgDown.disabled{background:url("/module/foreground/pc/packs/zoom/images/d_09.png") no-repeat; margin-left:375px; margin-top:-50px;}

#imageMenu {height:50px; width:360px; overflow:hidden; margin-left:0; float:left;}
#imageMenu li {height:50px; width:60px; overflow:hidden; float:left; text-align:center;}
#imageMenu li img{width:50px; height:50px;cursor:pointer; border:none;}
#imageMenu li#onlickImg img, #imageMenu li:hover img{ width:44px; height:44px; border:3px solid #959595;}
/* bigImg */
.bigImg{position:relative; float:left; width:402px; height:402px; /*width:322px; height:322px;*/ overflow:hidden;}
.bigImg #midimg{width:400px; height:400px; /*width:320px; height:320px;*/}
/************** 放大镜 @end@ **************/

</style>

<div id="goodsBrief">           
    <div id="goodsBrief_left">
        <div class="preview">
            <div id="vertical" class="bigImg">
                <img src="<?php echo $view_data['good_info']['image_norm'][0]; ?>" width="400" height="400" alt="" id="midimg" />
            </div><!--bigImg end-->	
            <div class="smallImg">
                <div class="scrollbutton smallImgUp disabled"></div>
                <div id="imageMenu">
                    <ul>
                        <?php foreach ($view_data['good_info']['image_thumb'] as $key => $thumb_item): ?>
                        <?php if(!empty($thumb_item)): ?>
                        <li <?php if($key == 0): ?>id="onlickImg"<?php endif; ?>><img src="<?php echo $thumb_item; ?>" width="68" height="68" alt=""/></li>
                        <?php endif; ?>                       
                        <?php endforeach; ?>
                    </ul>
                </div>
                <div class="scrollbutton smallImgDown"></div>
            </div><!--smallImg end-->
        </div>
        
        
    </div>
    
    <div id="goodsBrief_right">
        <h1 class="goodsName"><?php echo $view_data['good_info']['name'] ?></h1>
        <p class="goodsBriefLabel">
            价格：<span class="goodsPrice">￥<!--¥--> <?php echo $view_data['good_info']['min_price']; ?><?php if($view_data['good_info']['max_price'] > $view_data['good_info']['min_price']): ?> ～ <?php echo $view_data['good_info']['max_price']; ?><?php endif; ?></span>
            
        </p>
        
        <dl id="gspecsDl">
        	<!--<dt>规格：</dt> -->           
            <dd>
                 <table id="gspecs">
                    <thead>
                        <tr>
                        	<th class="gspecIdRadio no-sort no-filter no-search no-dropdown-filter-dropdown"></th>
                        	<?php foreach ($view_data['good_info']['sattr_list'] as $sattr): ?>
                            <th class="filter no-sort no-search"><?php echo $sattr['name']; ?></th>
                            <?php endforeach; ?>

                            <?php if(!$view_data['good_info']['if_show_number_grade']): ?>
                            <th class="no-sort no-filter no-search no-dropdown-filter-dropdown">价格</th>
                            <?php endif; ?>
                        </tr>
                    </thead>
                    
                    <tbody>
                        <?php if($view_data['good_info']['if_show_number_grade']): ?>
                        <?php $spec_number_grade_td_colspan_count = $view_data['good_info']['sattr_list_count'] + 1; ?>
                        <?php endif; ?>

                    	<?php $gspec_i = 0; ?>
                    	<?php foreach ($view_data['good_info']['spec_list'] as $spec_item): ?>
                        <?php $gspec_i++ ?>
                        <tr>

                            <td class="gspecIdRadio">
                            	<input type="radio" name="specId" value="<?php echo $spec_item['id']; ?>" <?php if($gspec_i == 1): ?>checked="checked"<?php endif;?> />
                            </td>

                            <?php foreach ($view_data['good_info']['sattr_list'] as $sattr): ?>
                            <td> <?php echo $spec_item['sattr_value_list'][$sattr['id']]['value']; ?></td>
                            <?php endforeach; ?>


                            <?php if(!$view_data['good_info']['if_show_number_grade']): ?>
                            <?php foreach ($view_data['good_info']['number_grade_list'] as $number_grade): ?>

                            <td class="goodsPrice">￥<!--¥--> <?php echo $spec_item['number_grade_price_list'][$number_grade['id']]['price']; ?></td>

                            <?php break; ?>
                            <?php endforeach; ?>
                            <?php endif; ?>
                            
                        </tr>


                        <?php if($view_data['good_info']['if_show_number_grade']): ?>
                        <tr class="spec_number_grade_tr">
                            <td colspan="<?php echo $spec_number_grade_td_colspan_count; ?>">
                                <table>
                                    <thead>
                                        <tr>
                                            <th>数量范围</th>
                                            <th>价格</th>
                                        </tr>
                                    </thead>

                                    <tbody>
                                        <?php foreach ($view_data['good_info']['number_grade_list'] as $number_grade): ?>
                                        <tr>
                                            <td>
                                                <span class="spec_number_grade_number_min"><?php echo $number_grade['number_min']; ?></span>-<span
                                                    class="spec_number_grade_number_max"><?php if($number_grade['number_max'] > 0): ?><?php echo $number_grade['number_max']; ?><?php else: ?>以上<?php endif; ?></span>
                                            </td>

                                            <td class="goodsPrice">￥<!--¥--> <?php echo $spec_item['number_grade_price_list'][$number_grade['id']]['price']; ?></td>

                                        </tr>
                                        <?php endforeach; ?>
                                    </tbody>

                                </table>
                            </td>
                        </tr>
                        <?php endif; ?>

                        <?php endforeach; ?>                        
                    </tbody>
                </table>             
            </dd>
        </dl>

        <ul id="addCartUl">
        	<li><span>数量：<input id="goodNumber" name="goodNumber" type="text" value="1" /></span></li>
        	<li><a href="javascript:void(0);" onclick="addCart(1);">立即购买</a></li>
            <li><a href="javascript:void(0);" onclick="addCart(0);">加入购物车</a></li>
        </ul>
    </div>
</div>
<div id="goodsDescription">
	<blockquote id="tabTitleBlock">
    	<ul>
        	<li class='active'>商品详情</li>
            <li>售后服务</li>
        </ul>
    </blockquote>
    
	<blockquote id="tabContentBlock">
        <div id="goodsDescriptionContent" class="tabDiv">
        	<ul id="gattrs">
            	<?php foreach($view_data['good_info']['attr_list'] as $attr): ?>
                <li title="<?php echo $attr['value'] ?>"><?php echo $attr['name'] ?>：<?php echo $attr['value'] ?></li>
                <?php endforeach; ?>
            </ul>        
            <?php echo $view_data['good_info']['description']; ?>
        </div>
        <div id="goodsHistoryContent" class="tabDiv">
            <pre><?php echo $view_data['good_info']['after_sale_service']; ?></pre>
        </div>
    </blockquote>
</div>


<script type="text/javascript">
var goodId   = '<?php echo $view_data['good_info']['id']; ?>';

function activeTab(activeIndex){
	
	if(!activeIndex){
		activeIndex = 0;
	}
	
	//活动标题
	$('#tabTitleBlock li').each(function(index, element) {
		if(index === activeIndex){
			$(this).addClass('active');
		}else{
			$(this).removeClass('active');
		}
	});
	
	//显示活动内容，隐藏其他内容
	$('#tabContentBlock .tabDiv').each(function(index, element) {
		if(index === activeIndex){
			$(this).show();
		}else{
			$(this).hide();
		}
	});	
}

function addCart(isBuyIm){
	$.ajax({
		type: 'POST',
		url: "<?php echo $this->get_url(array('route' => 'member_check'), true); ?>",
		//data: postData,
		dataType: 'json',
		success: function(rdataCheck){
			//alert(rdataCheck.message); return false;
			if(rdataCheck.status <= 0){
				//showGoLogin();
                show_prompt_message(rdataCheck.message);
        	}else{
        		var postData    = 'good_id=' + goodId;

        		var goodNumber  = $('#goodNumber').val();
        		postData       += '&good_number=' + goodNumber;

        		var specId = $('input[name="specId"]:checked').val();
        		if(typeof(specId) != 'undefined'){
        			postData += '&spec_id=' + specId;
        		}

        		$.ajax({
        			type: 'POST',
        			url: "<?php echo $this->get_url(array('route' => 'cart_add'), true); ?>",
        			data: postData,
        			dataType: 'json',
        			success: function(rdata){
        				if(rdata.status <= 0){
        					//alert(rdata.message);
                            show_prompt_message(rdata.message);
        				}else{
//        					alert(rdata.message);
        					show_prompt_message(rdata.message, function(){
                                if(isBuyIm == 1){
                                    window.top.location.replace('<?php echo $this->get_url(array('route' => 'cart_index'), true); ?>');
                                }
                            });
        				}
        			}
        		});
        	}
    	}
    });
}


$(function(){
	//初始化活动标题，活动标签
	activeTab();
	
	$('#tabTitleBlock li').click(function(){
		var activeIndex = $(this).index();
		activeTab(activeIndex);		
	});
	
	/************** 图片 @start@ **************/
	// 图片上下滚动
	var imageCount = $("#imageMenu li").length
	if(imageCount <= 6){
		$('.smallImgUp').addClass('disabled');
		$('.smallImgDown').addClass('disabled');
	}
	var count = imageCount - 5; /* 显示 6 个 li标签内容 */
	//var count = $("#imageMenu li").length - 1; /* 显示 6 个 li标签内容 */
	var interval = $("#imageMenu li:first").width();
	var curIndex = 0;
	
	$('.scrollbutton').click(function(){
		if( $(this).hasClass('disabled') ) return false;
		
		if ($(this).hasClass('smallImgUp')) --curIndex;
		else ++curIndex;
		
		$('.scrollbutton').removeClass('disabled');
		if (curIndex == 0) $('.smallImgUp').addClass('disabled');
		if (curIndex == count-1) $('.smallImgDown').addClass('disabled');
		
		$("#imageMenu ul").stop(false, true).animate({"marginLeft" : -curIndex*interval + "px"}, 600);
	});

    //点击到中图
    var midChangeHandler = null;
	
    $("#imageMenu li img").bind("click", function(){
		if ($(this).attr("id") != "onlickImg") {
			midChange($(this).attr("src").replace("thumb", "norm"));
			$("#imageMenu li").removeAttr("id");
			$(this).parent().attr("id", "onlickImg");
		}
	}).bind("mouseover", function(){
		if ($(this).attr("id") != "onlickImg") {
			window.clearTimeout(midChangeHandler);
			midChange($(this).attr("src").replace("thumb", "norm"));
			$(this).css({ "border": "3px solid #959595" });
		}
	}).bind("mouseout", function(){
		if($(this).attr("id") != "onlickImg"){
			$(this).removeAttr("style");
			midChangeHandler = window.setTimeout(function(){
				midChange($("#onlickImg img").attr("src").replace("thumb", "norm"));
			}, 100);
		}
	});
    function midChange(src) {
        $("#midimg").attr("src", src);
    }
	/************** 图片 @end@ **************/
});
</script>